package com.company;

import java.util.HashMap;
import java.util.Map;

public class BooksLog {

    public Map<String, String> bookslog = new HashMap<String, String>();

    private static BooksLog _instance;

    private BooksLog() {

    }

    public void addEntry(String itemName, String libId) {
        bookslog.put(itemName, libId);
    }


    public void removeEntry(String itemName) {
        if (bookslog.containsKey(itemName)) {
            bookslog.remove(itemName);
        }
    }

    public void display() {
        System.out.format("%-30s%-30s%-30s", "Library Id of User","Name of User","Item Issued");
        System.out.println("");
        System.out.println("----------------------------------------------------------------------------");
        System.out.println("");
        for (Object o : bookslog.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            System.out.format("%-30s%-30s%-30s", entry.getValue(), Login.getUser(entry.getValue().toString()), entry.getKey());
            System.out.println("");
        }
        System.out.println("-----------------------------------------------------------------------------");

    }

    public static BooksLog getInstance() {
        if (null == _instance) {
            _instance = new BooksLog();
        }
        return _instance;
    }
}
